<script>
$('#datas').datagrid({
				title:'产品列表',
				nowrap: true,
				fit:true,
				autoRowHeight: false,
				striped: true,
				method:'get',
				url:'index.php?c=products&m=lists',
				sortName: 'ProductID',
				sortOrder: 'desc',
				remoteSort: false,
				idField:'ProductID',
				fitColumns:true,
				columns:[[
					{field:'ck',checkbox:true},
					{field:'ProductName',title:'产品名称',width:100,sortable:true},
					{field:'CategoryName',title:'分类',width:100,rowspan:2,sortable:true},
					{field:'Inputtime',title:'时间',width:100,rowspan:2,sortable:true},
					{field:'ProductID',title:'操作',width:100,align:'center', rowspan:2,
						formatter:function(value,rec){
							return '<span style="color:red"><a href="javascript:edit('+value+')" >编辑</a> | <a href="javascript:del('+value+')">删除</a></span>';
						}
					}
				]],
				pagination:true,
				rownumbers:true,
				toolbar:[{
					id:'btnadd',
					text:'添加',
					iconCls:'icon-add',
					handler:function(){
						  $('#win').window({
						  	title:'添加产品',
						  	 href:'index.php?c=products&m=add',
   							 width:600,
     						 height:400,
     						 modal:true
 							 });
					}
				},'-',{
					id:'btncut',
					text:'删除',
					iconCls:'icon-cancel',
					handler:function(){
						$.messager.confirm('Confirm','确认删除这些选项？',function(r){
							if(r)
							{
								var result = [];
					            var rows = $('#datas').datagrid('getSelections');
					            for(var i=0;i < rows.length;i++)
					            {
					            	result.push(rows[i].NewsId);
					            }
					            if(result.length==0){
									$.messager.alert('提示','请选择！');
									return false;
								}
								else
								{
									$.post("index.php?c=products&m=delete",{ids:result},function(data){
										$.messager.alert('提示',data);
									});
									$("#datas").datagrid('reload');
								}

							}
							else
							{
								return false;
							}
						});
					}
				}]
			});

			function del(id)
			{
				$.messager.confirm('Confirm','确认删除这些选项？',function(r){
					if(r)
					{
						$.get("index.php",{c:"news",m:"delete",ids:id},function(data){
							$.messager.alert('提示',data);
						})
						$("#datas").datagrid('reload');
					}
				});
			}

			function edit(id)
			{
			  $('#win').window({
			  	title:'修改产品',
			  	 href:'index.php?c=products&m=update&id='+id,
				 width:600,
				 height:400,
				 modal:true
				 });
			}
</script>


<table id="datas"></table>
<div id="win" iconCls="icon-save" data-options="cache:false"></div>


